summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2013-08-09 09:40:01 -0400
committerBehdad Esfahbod <behdad@behdad.org>2013-08-09 09:40:01 -0400
commit10f964623f003c70f6bdd33423420abda3820ce0 (patch)
tree214f3ad1d5f5a5ba60aa021acb96f69aeba49b4b
parentdf8f70ae5de6181d56efa3f076f14e4d52119a5e (diff)
Round when scaling values
Doesn't matter for most users since they should be working in a fixed sub-pixel scale anyway (ie. 22.10, 26.6, 16.16, etc).
-rw-r--r--TODO2
-rw-r--r--src/hb-font-private.hh6
2 files changed, 5 insertions, 3 deletions
diff --git a/TODO b/TODO
index ef009e13..dee6e2e0 100644
--- a/TODO
+++ b/TODO
@@ -12,8 +12,6 @@ General fixes:
- Warn at compile time (and runtime with HB_DEBUG?) if no Unicode / font
funcs found / set.
-- Do proper rounding when scaling from font space? May be a non-issue.
-
- Misc features:
* init/medi/fina/isol for non-cursive scripts
diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh
index bdc6259e..acea1d72 100644
--- a/src/hb-font-private.hh
+++ b/src/hb-font-private.hh
@@ -461,7 +461,11 @@ struct hb_font_t {
}
private:
- inline hb_position_t em_scale (int16_t v, int scale) { return v * (int64_t) scale / face->get_upem (); }
+ inline hb_position_t em_scale (int16_t v, int scale)
+ {
+ unsigned int upem = face->get_upem ();
+ return (v * (int64_t) scale + upem / 2) / upem;
+ }
};
#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS