algoStyle = true;
boldness = 1.33f;
}
}
double[] matrix = new double[4];
AffineTransform at = desc.glyphTx;
at.getMatrix(matrix);
if (!desc.devTx.isIdentity() &&
desc.devTx.getType() != AffineTransform.TYPE_TRANSLATION) {
try {
invertDevTx = desc.devTx.createInverse();
} catch (NoninvertibleTransformException e) {
}
}
/* If any of the values is NaN then substitute the null scaler context.
* This will return null images, zero advance, and empty outlines
* as no rendering need take place in this case.
* We pass in the null scaler as the singleton null context
* requires it. However
*/
if (Double.isNaN(matrix[0]) || Double.isNaN(matrix[1]) ||
Double.isNaN(matrix[2]) || Double.isNaN(matrix[3]) ||
fileFont.getScaler() == null) {
pScalerContext = NullFontScaler.getNullScalerContext();
} else {
pScalerContext = fileFont.getScaler().createScalerContext(matrix,
fileFont instanceof TrueTypeFont,
desc.aaHint, desc.fmHint,
boldness, italic);
}
mapper = fileFont.getMapper();
int numGlyphs = mapper.getNumGlyphs();
/* Always segment for fonts with > 2K glyphs, but also for smaller
* fonts with non-typical sizes and transforms.
* Segmenting for all non-typical pt sizes helps to minimise memory
* usage when very many distinct strikes are created.
* The size range of 0->5 and 37->INF for segmenting is arbitrary
* but the intention is that typical GUI integer point sizes (6->36)
* should not segment unless there's another reason to do so.
*/
float ptSize = (float)matrix[3]; // interpreted only when meaningful.
int iSize = intPtSize = (int)ptSize;
boolean isSimpleTx = (at.getType() & complexTX) == 0;
segmentedCache =
(numGlyphs > SEGSIZE << 3) ||
((numGlyphs > SEGSIZE << 1) &&
(!isSimpleTx || ptSize != iSize || iSize < 6 || iSize > 36));
/* This can only happen if we failed to allocate memory for context.
* NB: in such case we may still have some memory in java heap
* but subsequent attempt to allocate null scaler context
* may fail too (cause it is allocate in the native heap).
* It is not clear how to make this more robust but on the
* other hand getting NULL here seems to be extremely unlikely.
*/
if (pScalerContext == 0L) {
/* REMIND: when the code is updated to install cache objects
* rather than using a switch this will be more efficient.
*/
this.disposer = new FontStrikeDisposer(fileFont, desc);
initGlyphCache();
pScalerContext = NullFontScaler.getNullScalerContext();
FontManager.deRegisterBadFont(fileFont);
return;
}
/* First, see if native code should be used to create the glyph.
* GDI will return the integer metrics, not fractional metrics, which
* may be requested for this strike, so we would require here that :
* desc.fmHint != INTVAL_FRACTIONALMETRICS_ON
* except that the advance returned by GDI is always overwritten by
* the JDK rasteriser supplied one (see getGlyphImageFromWindows()).
*/
if (FontManager.isWindows && isXPorLater &&
!FontManager.useT2K &&
!GraphicsEnvironment.isHeadless() &&
!fileFont.useJavaRasterizer &&
(desc.aaHint == INTVAL_TEXT_ANTIALIAS_LCD_HRGB ||
desc.aaHint == INTVAL_TEXT_ANTIALIAS_LCD_HBGR) &&
(matrix[1] == 0.0 && matrix[2] == 0.0 &&
matrix[0] == matrix[3] &&
matrix[0] >= 3.0 && matrix[0] <= 100.0) &&
!((TrueTypeFont)fileFont).useEmbeddedBitmapsForSize(intPtSize)) {
useNatives = true;
}
//ae else if (fileFont.checkUseNatives() && desc.aaHint==0 && !algoStyle) {
// /* Check its a simple scale of a pt size in the range
// * where native bitmaps typically exist (6-36 pts) */
// if (matrix[1] == 0.0 && matrix[2] == 0.0 &&
// matrix[0] >= 6.0 && matrix[0] <= 36.0 &&
// matrix[0] == matrix[3]) {
// useNatives = true;
// int numNatives = fileFont.nativeFonts.length;
// nativeStrikes = new NativeStrike[numNatives];
// /* Maybe initialise these strikes lazily?. But we
// * know we need at least one
// */
// for (int i=0; i<numNatives; i++) {
// nativeStrikes[i] =
// new NativeStrike(fileFont.nativeFonts[i], desc, false);
// }
// }
// }
if (FontManager.logging && FontManager.isWindows) {
FontManager.logger.info
("Strike for " + fileFont + " at size = " + intPtSize +
" use natives = " + useNatives +
" useJavaRasteriser = " + fileFont.useJavaRasterizer +
" AAHint = " + desc.aaHint +
" Has Embedded bitmaps = " +
((TrueTypeFont)fileFont).
useEmbeddedBitmapsForSize(intPtSize));
}
this.disposer = new FontStrikeDisposer(fileFont, desc, pScalerContext);
/* Always get the image and the advance together for smaller sizes
* that are likely to be important to rendering performance.
* The pixel size of 48.0 can be thought of as
* "maximumSizeForGetImageWithAdvance".
* This should be no greater than OutlineTextRender.THRESHOLD.
*/
double maxSz = 48.0;
getImageWithAdvance =
Math.abs(at.getScaleX()) <= maxSz &&
Math.abs(at.getScaleY()) <= maxSz &&
Math.abs(at.getShearX()) <= maxSz &&
Math.abs(at.getShearY()) <= maxSz;
/* Some applications request advance frequently during layout.
* If we are not getting and caching the image with the advance,
* there is a potentially significant performance penalty if the
* advance is repeatedly requested before requesting the image.