You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if ((float)currentbytes/maxbytes<1) fontsize*=(1-(float)currentbytes/maxbytes)/2+1;
255
-
paint.setTextSize(fontsize);
254
+
//i wasted so many days just to find out that my first formula works best :(
255
+
if ((float)currentbytes/maxbytes<1) fontsize*=(1-(float)currentbytes/maxbytes)/2+1; //works in about 18 iterations
256
+
//if ((float)currentbytes/maxbytes<1) fontsize = fontsize * (int)(0+((1*(Math.exp(-currentbytes+(maxbytes/2)))+maxbytes)/maxbytes)-0); //not working at all, hits the cap
inttextWidth = (int) (paint.measureText(text) + pad * 2);
258
263
intheight = (int) (fontsize / 0.7);
259
264
currentbytes = (textWidth * height * 4);
260
265
//Log.d(TAG, "calculatefontsize: itaration "+count+", fontsize "+fontsize+", size is "+currentbytes+", that is "+((float)currentbytes/maxbytes));
266
+
if (count>cap) break;
261
267
}
262
-
//Log.d(TAG, "calculatefontsize: using "+currentbytes+" of "+maxbytes);
263
268
fontsize--;
269
+
paint.setTextSize(fontsize);
270
+
{
271
+
intpad = (fontsize / 9);
272
+
inttextWidth = (int) (paint.measureText(text) + pad * 2);
273
+
intheight = (int) (fontsize / 0.7);
274
+
currentbytes = (textWidth * height * 4);
275
+
}
276
+
while (currentbytes > maxbytes) {
277
+
fontsize--;
278
+
count++;
279
+
paint.setTextSize(fontsize);
280
+
intpad = (fontsize / 9);
281
+
inttextWidth = (int) (paint.measureText(text) + pad * 2);
282
+
intheight = (int) (fontsize / 0.7);
283
+
currentbytes = (textWidth * height * 4);
284
+
//Log.d(TAG, "calculatefontsize: subtratcting itaration "+count+", fontsize "+fontsize+", size is "+currentbytes+", that is "+((float)currentbytes/maxbytes));
285
+
if (count>cap*2) break;
286
+
}
287
+
//Log.d(TAG, "calculatefontsize: using "+currentbytes+" of "+maxbytes+", that is "+((float)currentbytes/maxbytes));
264
288
//Log.d(TAG, "calculatefontsize: calculated font size is "+fontsize);
0 commit comments