summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2012-04-09 12:01:57 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2012-04-09 12:01:57 +0000
commit65b128b0881c647451182ac3c17992df5f482367 (patch)
tree49693b27cc31091c058271cde574745d2eaab29d
parentf13f2468b15a6e80f009833a62e3fc00372007ed (diff)
downloadnetsurf-65b128b0881c647451182ac3c17992df5f482367.tar.gz
netsurf-65b128b0881c647451182ac3c17992df5f482367.tar.bz2
Just get glyph widths rather than the entire glyph when calculating sizes.
This should be faster but isn't (probably still rendering the glyph internally) svn path=/trunk/netsurf/; revision=13843
-rw-r--r--amiga/font.c60
1 files changed, 49 insertions, 11 deletions
diff --git a/amiga/font.c b/amiga/font.c
index 54b943de8..213afbb38 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -78,6 +78,8 @@ ULONG ami_xdpi;
int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth);
+int32 ami_font_width_glyph(struct OutlineFont *ofont,
+ uint16 char1, uint16 char2, uint32 emwidth);
struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
BOOL fallback);
static void ami_font_cleanup(struct MinList *ami_font_list);
@@ -161,8 +163,7 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
utf16next = utf16[utf16charlen];
- tempx = ami_font_plot_glyph(ofont, NULL, *utf16, utf16next,
- 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
if(tempx == 0)
{
@@ -173,14 +174,12 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
if(ufont)
{
- tempx = ami_font_plot_glyph(ufont, NULL, *utf16, utf16next,
- 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ufont, *utf16, utf16next, emwidth);
}
/*
if(tempx == 0)
{
- tempx = ami_font_plot_glyph(ofont, NULL, 0xfffd, utf16next,
- 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ofont, NULL, 0xfffd, utf16next, emwidth);
}
*/
}
@@ -282,7 +281,7 @@ bool nsfont_split(const plot_font_style_t *fstyle,
}
}
- tempx = ami_font_plot_glyph(ofont, NULL, *utf16, utf16next, 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
if(tempx == 0)
{
@@ -293,14 +292,12 @@ bool nsfont_split(const plot_font_style_t *fstyle,
if(ufont)
{
- tempx = ami_font_plot_glyph(ufont, NULL, *utf16, utf16next,
- 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ufont, *utf16, utf16next, emwidth);
}
/*
if(tempx == 0)
{
- tempx = ami_font_plot_glyph(ofont, NULL, 0xfffd, utf16next,
- 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ofont, 0xfffd, utf16next, emwidth);
}
*/
}
@@ -568,6 +565,47 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
return char_advance;
}
+int32 ami_font_width_glyph(struct OutlineFont *ofont,
+ uint16 char1, uint16 char2, uint32 emwidth)
+{
+ int32 char_advance = 0;
+ FIXED kern = 0;
+ struct MinList *gwlist;
+ FIXED char1w;
+ struct GlyphWidthEntry *gwnode;
+
+ if(ESetInfo(&ofont->olf_EEngine,
+ OT_GlyphCode, char1,
+ OT_GlyphCode2, char1,
+ TAG_END) == OTERR_Success)
+ {
+ if(EObtainInfo(&ofont->olf_EEngine,
+ OT_WidthList, &gwlist,
+ TAG_END) == 0)
+ {
+ gwnode = GetHead((struct MinList *)gwlist);
+ char1w = gwnode->gwe_Width;
+
+ kern = 0;
+
+ if(char2) {
+ if(ESetInfo(&ofont->olf_EEngine,
+ OT_GlyphCode, char1,
+ OT_GlyphCode2, char2,
+ TAG_END) == OTERR_Success)
+ {
+ EObtainInfo(&ofont->olf_EEngine,
+ OT_TextKernPair, &kern,
+ TAG_END);
+ }
+ }
+ char_advance = (ULONG)(((char1w - kern) * emwidth) / 65536);
+ }
+ }
+
+ return char_advance;
+}
+
uint16 ami_font_translate_smallcaps(uint16 utf16char)
{
uint16 *p;