/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// IDWriteFontFileLoader methods /** * Important! Note the key here has to be a uint64_t that will have been * generated by incrementing sNextFontFileKey.
*/ virtual HRESULT STDMETHODCALLTYPE CreateStreamFromKey( voidconst* fontFileReferenceKey, UINT32 fontFileReferenceKeySize,
OUT IDWriteFontFileStream** fontFileStream);
/** * Gets the singleton loader instance. Note that when using this font * loader, the key must be a uint64_t that has been generated by incrementing * sNextFontFileKey. * Also note that this is _not_ threadsafe.
*/ static IDWriteFontFileLoader* Instance() { if (!mInstance) {
mInstance = new DWriteFontFileLoader();
Factory::GetDWriteFactory()->RegisterFontFileLoader(mInstance);
} return mInstance;
}
class DWriteFontFileStream final : public IDWriteFontFileStream { public: explicit DWriteFontFileStream(uint64_t aFontFileKey);
/** * Used by the FontFileLoader to create a new font stream, * this font stream is created from data in memory. The memory * passed may be released after object creation, it will be * copied internally. * * @param aData Font data
*/ bool Initialize(uint8_t* aData, uint32_t aSize);
already_AddRefed<UnscaledFont> NativeFontResourceDWrite::CreateUnscaledFont(
uint32_t aIndex, const uint8_t* aInstanceData,
uint32_t aInstanceDataLength) { if (aIndex >= mNumberOfFaces) {
gfxWarning() << "Font face index is too high for font resource."; return nullptr;
}
IDWriteFontFile* fontFile = mFontFile;
RefPtr<IDWriteFontFace> fontFace; if (FAILED(mFactory->CreateFontFace(mFaceType, 1, &fontFile, aIndex,
DWRITE_FONT_SIMULATIONS_NONE,
getter_AddRefs(fontFace)))) {
gfxWarning() << "Failed to create font face from font file data."; return nullptr;
}
RefPtr<UnscaledFont> unscaledFont = new UnscaledFontDWrite(fontFace, nullptr);
return unscaledFont.forget();
}
} // namespace gfx
} // namespace mozilla
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.