Esempio n. 1
0
        // Purge all caches, useful in low memory conditions
        public void purgeCaches()
        {
            std::lock_guard <std::recursive_mutex> _l = new std::lock_guard <std::recursive_mutex>(gMinikinLock);
            LayoutCache layoutCache = LayoutEngine.getInstance().layoutCache.functorMethod;

            layoutCache.clear();
            purgeHbFontCacheLocked();
        }
Esempio n. 2
0
        // Creates new FontFamily based on this family while applying font variations.
        // Returns nullptr if none of variations apply to this family.
        //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#:
        //ORIGINAL LINE: FontFamily createFamilyWithVariation(const ClassicVector<FontVariation>& variations) const;
        public FontFamily createFamilyWithVariation(List <FontVariation> variations)
        {
            if (variations.Count == 0 || mSupportedAxes.empty())
            {
                return(null);
            }

            bool hasSupportedAxis = false;

            foreach (FontVariation variation in variations)
            {
                if (mSupportedAxes.find(variation.axisTag) != mSupportedAxes.end())
                {
                    hasSupportedAxis = true;
                    break;
                }
            }
            if (!hasSupportedAxis)
            {
                // None of variation axes are suppored by this family.
                return(null);
            }

            List <Font> fonts = new List <Font>();

            foreach (Font font in mFonts)
            {
                bool supportedVariations = false;
                std::lock_guard <std::recursive_mutex> _l = new std::lock_guard <std::recursive_mutex>(gMinikinLock);
                HashSet <AxisTag> supportedAxes           = font.getSupportedAxesLocked();
                if (supportedAxes.Count > 0)
                {
                    foreach (FontVariation variation in variations)
                    {
                        if (supportedAxes.find(variation.axisTag) != supportedAxes.end())
                        {
                            supportedVariations = true;
                            break;
                        }
                    }
                }
                MinikinFont minikinFont;
                if (supportedVariations)
                {
                    minikinFont = font.typeface.createFontWithVariation(variations);
                }
                if (minikinFont == null)
                {
                    minikinFont = font.typeface;
                }
                fonts.Add(Font(std::move(minikinFont), font.style));
            }

            return(new FontFamily(mLangId, mVariant, std::move(fonts)));
        }
Esempio n. 3
0
        // TODO: Good to expose FontUtil.h.
        public bool analyzeStyle(MinikinFont typeface, ref int weight, ref bool italic)
        {
            std::lock_guard <std::recursive_mutex> _l = new std::lock_guard <std::recursive_mutex>(gMinikinLock);
            uint   os2Tag   = MinikinFont.MakeTag('O', 'S', '/', '2');
            HbBlob os2Table = new HbBlob(getFontTable(typeface.get(), new uint(os2Tag)));

            if (os2Table.get() == null)
            {
                return(false);
            }
            return(global::minikin.analyzeStyle(os2Table.get(), os2Table.size(), weight, italic));
        }
Esempio n. 4
0
        public float measureText(UInt16 buf, int start, int count, int bufSize, bool isRtl, FontStyle style, MinikinPaint paint, FontCollection collection, ref float advances)
        {
            std::lock_guard <std::recursive_mutex> _l = new std::lock_guard <std::recursive_mutex>(gMinikinLock);

            LayoutContext ctx = new LayoutContext();

            //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created:
            //ORIGINAL LINE: ctx.style = style;
            ctx.style.CopyFrom(style);
            //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created:
            //ORIGINAL LINE: ctx.paint = paint;
            ctx.paint.CopyFrom(paint);

            float advance = doLayoutRunCached(buf, start, count, bufSize, isRtl, ctx, 0, collection, null, advances);

            ctx.clearHbFonts();
            return(advance);
        }
Esempio n. 5
0
        public void computeCoverage()
        {
            std::lock_guard <std::recursive_mutex> _l = new std::lock_guard <std::recursive_mutex>(gMinikinLock);
            FontStyle   defaultStyle = new FontStyle();
            MinikinFont typeface     = getClosestMatch(defaultStyle).font;
            uint        cmapTag      = MinikinFont.MakeTag('c', 'm', 'a', 'p');
            HbBlob      cmapTable    = new HbBlob(getFontTable(typeface, new uint(cmapTag)));

            if (cmapTable.get() == null)
            {
                ALOGE("Could not get cmap table size!\n");
                return;
            }
            mCoverage = CmapCoverage.getCoverage(cmapTable.get(), cmapTable.size(), mHasVSTable);

            for (int i = 0; i < mFonts.size(); ++i)
            {
                HashSet <AxisTag> supportedAxes = mFonts[i].getSupportedAxesLocked();
                mSupportedAxes.insert(supportedAxes.GetEnumerator(), supportedAxes.end());
            }
        }
Esempio n. 6
0
        //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#:
        //ORIGINAL LINE: android::hash_t hash() const;
        //C++ TO C# CONVERTER TODO TASK: The implementation of the following method could not be found:
        //  android::hash_t hash();

        // Looks up a language list from an internal cache and returns its ID.
        // If the passed language list is not in the cache, registers it and returns
        // newly assigned ID.
        public uint registerLanguageList(string languages)
        {
            std::lock_guard <std::recursive_mutex> _l = new std::lock_guard <std::recursive_mutex>(gMinikinLock);

            return(FontLanguageListCache.getId(languages));
        }