JPEXS Free Flash Decompiler Issue Tracker

If you are looking for the decompiler itself, visit

: The issue tracker is now writable again and logged users can download files too. But note that our support is very LIMITED.

List of issuesList of issues

#541 How to calculate GlyphAdvance
Author: user rendu2mai
Date created:
Type: question
Visibility: Everybody
Assigned to: admin JPEXS
Labels: Text
State: closed Help

I'm trying to make a small tool to extract Text string. And some problem come out while I'm dealing with DefineText. Now I know it's related to DefineFont, such as GlyphIndex is the index of the character in the specified font. However, I cannot calculate GlyphAdvance. I found some Font have FontAdvance value, so text.GlyphAdvance = font.FontAdvance * text.TextHeight /20480. But some Font donot have FontAdvance value. Would you pls tell me how to calculate those who donot have FontAdvance value?
What you want glyph advance for? You want to modify text? If you want to add new character to a text, you need glyphindex and glyphadvance. If the font "has layout", then it is easy, you take advance value from font advance table for the glyph. If the font does not contain advance table, then you can't do anything about this. Fonts without advanced table are usually generated for static texts when there is no need to insert new text at runtime. Only thing you "can" do is to get the font name and in your application get advance value from that font installed on your machine. This unfortunately depends on installed system fonts:-(. In java, I do it this way: Font fnt = new Font(fontName, fontStyle, 1024); glyphAdvance = getDivider() * Math.round(fnt.createGlyphVector((new JPanel()).getFontMetrics(fnt).getFontRenderContext(), "" + character).getGlyphMetrics(0).getAdvanceX();
State: new→opened
Assigned:admin JPEXS
Ok, thanks a lot. I'll try another way, just use TextHeight instead of GlyphAdvance as Chinese font have the same Advance which happens to be TextHeight .
State: opened→closed