Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8307499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:32:13+00:00 2026-06-08T18:32:13+00:00

I am creating a Font Mapping program where I want to map 2 fonts

  • 0

I am creating a Font Mapping program where I want to map 2 fonts of different languages.

For eg A in Arial Font(English) will map with अ in Kruti Dev Font(Hindi).

I have a created this conversion in a database this way:

Native_Font     |     Foreign_Language_Font
-------------------------------------------
       A        |              अ
       B        |              बी

If conversion was restricted only for characters it was OK. Read each character of native font and find its matching character in Foreign Language Font. (I have done it)

But now I have to do it for strings also and that’s where the real problem starts.

If a string is provided in database, then convert it fully. But if its conversion does not exist find conversion for one character less.

An example would be

In Database

Native_Font     |     Foreign_Language_Font
-------------------------------------------
    Cha         |              चा
     r          |              र
     t          |              ट

and word Chart is given to translate.

  1. It would first try to convert Full word Chart. If its mapping is found give at once.
  2. But if it does not find direct conversion for Chart then Go for Char. If its mapping is found give at once, then find respective character of t

and so on

Chart

Char t

Cha rt
Cha r t

Ch art
Ch ar t
Ch a r t

C hart
C har t
C ha r t
C h a r t

Moreover if a mapping is not found, it should be replaced by native font character. How to do it? I am sure recursion should be used. But How?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:32:16+00:00Added an answer on June 8, 2026 at 6:32 pm

    I’d approach it with a greedy algorithm. Something like this:

        // warning, untested
        public String Translate(String s, Dictionary<String, String> mapping)
        {
            String result = "";
            if (RecurTranslate(s, mapping, ref result))
                return result;
    
            throw new Exception("No translation");
        }
    
        private bool RecurTranslate(String s, Dictionary<String, String> mapping, ref String result)
        {
            if (s.Length == 0)
                return true;
    
            for (int prefixLen = s.Length; prefixLen > 0; --prefixLen)
            {
                String prefix = s.Substring(0, prefixLen);
                String trans;
                if (mapping.TryGetValue(prefix, out trans))
                {
                    if (RecurTranslate(s.Substring(prefixLen), mapping, ref result))
                    {
                        result = trans + result;
                        return true;
                    }
                }
                else if (prefixLen == 1)
                {   // this branch allows a character to stand for itself
                    if (RecurTranslate(s.Substring(prefixLen), mapping, ref result))
                    {
                        result = prefix + result;
                        return true;
                    }
                }
            }
    
            return false;
        }
    

    This starts from the front, looking for the largest possible match. Depending on your data, other approaches might be better – say, going through the mapping in length order to find the longest match and splitting from there:

        private bool RecurTranslate2(String s, Dictionary<String, String> mapping, ref String result)
        {
            if (s.Length == 0)
                return true;
    
            foreach (var entry in mapping.Where(e => e.Key.Length <= s.Length).OrderByDescending(e => e.Key.Length))
            {
                if (s.Contains(entry.Key))
                {   // split into a before and after
                    int idx = s.IndexOf(entry.Key);
                    String before = s.Substring(0, idx);
                    String after = s.Substring(idx + entry.Key.Length);
                    String bRes = "", aRes = "";
                    if (RecurTranslate2(before, mapping, ref bRes) && RecurTranslate2(after, mapping, ref aRes))
                    {
                        result = aRes + entry.Value + bRes;
                        return true;
                    }
                }
            }
    
            return false;
        }
    

    Finally, you might play with combining these methods: use RecurTranslate2 until you get to some length threshold and then switch to RecurTranslate.

    Responding to comment: See new else branch for failed lookup

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an installer that also needs to delete the Arial font (I
I am creating a notepad android app that has different fonts to use. I
if creating a dictionary program. when use copy some text on clipboard it will
I'm creating a game in OpenGL which loads the entire Arial Unicode MS font
I am creating a website and the font looks different in IE (it's larger)
I'm usually creating 1 .as file per font and exports these .as files to
I am creating application where in i have used preferences for changing font settings.
I have problems with creating a simple Group-Box-Control via CreateWindowEx. The font-size/-style of its
Creating a google map with store locations within 50 miles of user entered address.
Creating a server-side socket will fail if I'm trying to use the same port

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.