fbritop Active Member Licensed User Longtime User Mar 25, 2019 #1 Is there an alternative way to calculate the label width with different typeface? B4X: cs.Initialize().Typeface(Typeface.FONTAWESOME).Size(Starter.subTitleSize).Color(color.appBlue).Append(Chr(0xF038)).PopAll cs.Typeface(fontNormal).Size(Starter.subtitleSize).Color(color.appBlue).Append("LOG").PopAll l3.Text=cs l3.width=cv.MeasureStringWidth(cs, fontNormal, Starter.subTitleSize) I have to go two times to actually get the FONTAWESOME and the fontNormal width´s in order to get the total width. With this method FONTAWESOME are not being considered. Thanks FBP
Is there an alternative way to calculate the label width with different typeface? B4X: cs.Initialize().Typeface(Typeface.FONTAWESOME).Size(Starter.subTitleSize).Color(color.appBlue).Append(Chr(0xF038)).PopAll cs.Typeface(fontNormal).Size(Starter.subtitleSize).Color(color.appBlue).Append("LOG").PopAll l3.Text=cs l3.width=cv.MeasureStringWidth(cs, fontNormal, Starter.subTitleSize) I have to go two times to actually get the FONTAWESOME and the fontNormal width´s in order to get the total width. With this method FONTAWESOME are not being considered. Thanks FBP
Erel B4X founder Staff member Licensed User Longtime User Mar 26, 2019 #2 Canvas.MeasureStringWidth expects a string, not a CharSequence (CSBuilder). It will ignore the string attributes. I guess that the simplest solution will be to add a small gap as a compensation for this. Upvote 0
Canvas.MeasureStringWidth expects a string, not a CharSequence (CSBuilder). It will ignore the string attributes. I guess that the simplest solution will be to add a small gap as a compensation for this.