473,388 Members | 1,286 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

getting font from file

I am developing one application in java(swing) font converter. In which I have to upload .doc file .Then if that file contains marathi,english text then I want to change marathi font to unicode.My converter program is completed.Now problem is that how I get marathi font or any other non unicode font from file whcih I want to unicode?
Thanks in advance.
Dinesh
Jun 21 '07 #1
4 3004
get ur file .doc which contains the marathi or any other code and load it in to your swing .
1.
// String documentPath = "C:\\whateverThePathIs.doc";
// 2.
// String command = "cmd /c start " + documentPath ;
// 3.
// Runtime.getRuntime().exec(command);
//

use this code to load ur file and let me know if it works or not....

I am developing one application in java(swing) font converter. In which I have to upload .doc file .Then if that file contains marathi,english text then I want to change marathi font to unicode.My converter program is completed.Now problem is that how I get marathi font or any other non unicode font from file whcih I want to unicode?
Thanks in advance.
Dinesh
Jun 21 '07 #2
get ur file .doc which contains the marathi or any other code and load it in to your swing .
1.
// String documentPath = "C:\\whateverThePathIs.doc";
// 2.
// String command = "cmd /c start " + documentPath ;
// 3.
// Runtime.getRuntime().exec(command);
//

use this code to load ur file and let me know if it works or not....
I am sorry. I have not mentioned I am using linux.
How do I do it in linux?
Jun 21 '07 #3
import java.io.*;



class runExtApp{
String arr[]=null;
public void runfunc(){

try{
Runtime.getRuntime().exec("oowriter -o /home/the exact path where your file exists");
}catch(IOException e){
System.out.println(e);
}
}

}
public class Mainpro{

public static runExtApp runapp =new runExtApp();

public static void main(String[]args){

runapp.runfunc();

}


}





if possible plz mail me your font converter program i will check it out l8r.....

<email removed use PMs :ADMIN>
I am sorry. I have not mentioned I am using linux.
How do I do it in linux?
Jun 21 '07 #4
import java.io.*;



class runExtApp{
String arr[]=null;
public void runfunc(){

try{
Runtime.getRuntime().exec("oowriter -o /home/the exact path where your file exists");
}catch(IOException e){
System.out.println(e);
}
}

}
public class Mainpro{

public static runExtApp runapp =new runExtApp();

public static void main(String[]args){

runapp.runfunc();

}


}





if possible plz mail me your font converter program i will check it out l8r.....

<email removed use PMs :ADMIN>

Hello,
I think you have not got my problem.I dont want to open .doc file directely.
My program should be read that .doc file. Then program should able to get
only specific font(say marathi,hindi.dvbttyogesh) data from that file and convert it to unicode.
At this stage my program converts all file contents to unicode.

Following is my program......

package GuiProjectPac;
import java.io.*;
import java.util.*;
import java.net.*;

public class FileJavaNew5

{ //%%%%%% Command line arg with expection%%%%%
/*public String args[0];
public String args1;
public String args2;*/

public static HashMap mp= new HashMap();
public static TreeSet ts =new TreeSet();
public static TreeMap tm =new TreeMap();
public static Set set;
public static Vector vec= new Vector();
public static boolean DEBUG =false;
public static String delim = "\r\t\n ";

public static String map="";
public static String ip="";
public static String op="";

public static class CusResult {
public String lbound;
public String ubound;
public int ret=0;
public CusResult() {
lbound = "";
ubound = "";
ret = 0;
}
public String getLBound() {
return lbound;
}
public String getUBound() {
return ubound;
}
public int getRet() {
return ret;
}
public void setLBound(String l) {
lbound = l;
}
public void setUBound(String u) {
ubound = u;
}
public void setRet(int r) {
ret = r;
}
}
public static void Conmain (String arg1,String arg2,String arg3)
{
map=arg1;
ip=arg2;
op=arg3;

//System.out.println("Fist give map file then Input file & OutputFile");
/* int i=args.length;
int j=3;
System.out.println(i);*/
try
{
/*if(args.length==3)
System.out.println(" ok");
else
System.out.println(" plz Give Totle Paramerter as Mention");
*/


FileInputStream fin;
String tk=null;


fin = new FileInputStream (map);
DataInputStream in = new DataInputStream(fin);
while (in.available() !=0)
{
tk = in.readLine();
StringTokenizer st = new StringTokenizer(tk," \n");
while(st.hasMoreTokens())
{
String key= st.nextToken();
String val= st.nextToken();
tm.put(key,val);//Entered value in Map
}
}
//System.out.println("Asending Map :");
Set set = tm.entrySet();

Iterator tit =set.iterator();
while(tit.hasNext()){
Map.Entry me =(Map.Entry)tit.next();
//System.out.println(me.getKey()+":"+me.getValue());

}




fin.close();
}
catch (IOException e)
{
System.err.println ("Unable to read from file1");
System.exit(-1);
}
catch (ArrayIndexOutOfBoundsException e)
{
System.err.println ("it catch "+e);
System.exit(-1);
}

//mappingFileBegin();//call to vector map funct1ion
//System.out.println("Vec :"+vec.firstElement().toString());
//opening input file
FileInputStream finIn;
FileOutputStream finOut;
String line=null;
String uniLine=null;
try
{
finIn = new FileInputStream (ip);
DataInputStream in = new DataInputStream(finIn);

finOut = new FileOutputStream (op);

DataOutputStream out = new DataOutputStream(finOut);

while (in.available() !=0)
{
line = in.readLine();
uniLine=convertLine(line);
//out.writeChars(uniLine);
out.writeBytes(uniLine);
out.writeByte('\n');
//out.writeUTF(uniLine);
}
finIn.close();
finOut.close();
if(uniLine.length()>0)
{
//System.out.println("o/p File Contents:"+uniLine);
// outfptr<<uniLine<<endl;
}}
catch (IOException e)
{
System.err.println ("Unable to read from file 2");
System.exit(-1);
}

catch (ArrayIndexOutOfBoundsException e)
{
System.err.println ("yogesh"+e);
System.exit(-1);
}
}


public static boolean isdelim(char ch){
for(int i=0;i<delim.length();i++)
{
if(delim.charAt(i)==ch)
return true;
}
return false;
// return(delim.contains(ch));
}
public static String convertLine(String line)
{ char linechar[]=line.toCharArray();
int len = line.length();
String word="";
String uniWord="";
String uniLine="";

if(line.length()==0)
return "";
if(DEBUG)
{
System.out.println("Input Line:"+line);
System.out.println("Length Of Input Line:"+len);
}
for(int i=0;i<len;i++){
if(isdelim(linechar[i])){
if(word.length()!=0){
if(DEBUG != false)
System.out.println("Converting Word:"+word);
uniWord = convertWord(word);
if(DEBUG!=false)
System.out.println("\nConverted Word: "+uniWord);
uniLine += uniWord;
word="";
uniWord="";
//System.out.println("dinesh:"+linechar[i]);
}
uniLine += linechar[i];
}
else
{
word += linechar[i];
if(DEBUG)
System.out.println("Current Word:"+word);
}
// System.out.println("yogesh:"+linechar[i]);
}
if(word.length()!=0){
if(DEBUG)
System.out.println("Converting Word:"+word);

uniWord = convertWord(word);

if(DEBUG)
System.out.println("\nConverted Word: "+uniWord);;
uniLine += uniWord;

word="";
uniWord="";
}
if(DEBUG)
System.out.println("Returning from convertLine: "+uniLine);
return uniLine;
}

public static String convertWord(String word){
CusResult objCus = new CusResult();
char Charword[]=word.toCharArray();
String akshar="";
String uniWord="";
String cached_result="";

int len = word.length();
int i,bound_result=0;
int flag=0;
// mitr lower_bound,upper_bound,itr;->
String lower_bound= new String("");
String upper_bound= new String("");

if(DEBUG)
System.out.println("Input Word: ["+word+"]");

// lower_bound=tm.firstEntry().toString();
// upper_bound=tm.lastEntry().toString();
for(i=0;i<len;i++){
if(flag==0){ //-->if (flag==0 && word[i]){
akshar += Charword[i];
if(DEBUG) {
System.out.println("\nreading "+Charword[i]);
}
}
if(DEBUG)
System.out.println("\ncalling lower bound with "+akshar);
//bound_result = custom_bounds(akshar,lower_bound,upper_bound);
objCus = custom_bounds(akshar,lower_bound,upper_bound);
flag=0;
bound_result = objCus.getRet();
lower_bound = objCus.getLBound();
upper_bound = objCus.getUBound();
// Switch Remaining...
switch(bound_result){
case 0: //no entry found in mapping
if(DEBUG)
System.out.println("No results found, Cache: "+cached_result);
if(cached_result.length()!=0){//there was some result before adding last char,
//use last found result (if single), and start afresh with last added char
uniWord += cached_result;
cached_result="";
// System.out.println("Cahe Akasher1 :"+akshar);
int aks=akshar.length()-1;
akshar = akshar.substring(aks,aks+1);//->akshar = akshar[akshar.size()-1];
// System.out.println("Cahe Akasher2 :"+akshar);
i--;
flag =1;
}
else{
//we have encountered a single char which doesnt start any mapping entry, append it as it to o/p and move ahead.
uniWord += akshar;
akshar="";
}
// lower_bound = tm.firstEntry().toString();
//upper_bound = tm.lastEntry().toString();
lower_bound = tm.firstKey().toString();
upper_bound = tm.lastKey().toString();
break;
case 1: //exactly one result, cache it
// cached_result = lower_bound->second;//Remain
// System.out.println("Exact Match :"+lower_bound);
//cached_result =mp.get(lbound1G).toString();
cached_result = "";
cached_result =cached_result+lower_bound;
break;
case 2: //multiple results
// if(lower_bound->first == akshar)
// cached_result = lower_bound->second;

// if(lbound1G == akshar) //exact match found in first entry, cache it
//cached_result = mp.get(lbound1G).toString();
// System.out.println("Mul Match Lower :"+lower_bound + " Mul Upper :" + upper_bound);
cached_result = lower_bound;
// System.out.println("Lower Bound:"+lbound1G+" AksharExact:"+akshar+"cached_result:"+cached_resul t);
break;
}
}
if(cached_result.length()>0)
uniWord += cached_result;
if(DEBUG)
System.out.println("Returning from convertWord: "+uniWord);
return uniWord;
}


public static CusResult custom_bounds(String akshar,String lbound1,String ubound1){
CusResult objCusResult = new FileJavaNew5.CusResult();
Set set = tm.entrySet();
Iterator tit =set.iterator();
int alen=akshar.length();
//System.out.println("Cus Akshar :"+akshar);
String tmp="";
String tmp1="";
int count=0;
while(tit.hasNext()){
Map.Entry me =(Map.Entry)tit.next();
tmp=me.getKey().toString();
count++;
//System.out.println("Sub String :" +tmp.substring(0,alen));
if(tmp.length()>=alen) {
if(tmp.substring(0,alen).equals(akshar)) {
tmp1=me.getValue().toString();
break;
}
}
}
if(tit.hasNext() == false) // if no match found
//return 0;
return objCusResult;
lbound1 = tmp1;

NavigableMap nmp = tm.descendingMap();
set = nmp.entrySet();
tit = set.iterator();
while(tit.hasNext()){
Map.Entry me =(Map.Entry)tit.next();
tmp=me.getKey().toString();
if(tmp.length()>=alen) {
if(tmp.substring(0,alen).equals(akshar)) {
tmp1=me.getValue().toString();
break;
}
}
}
//System.out.println("Upper = "+tmp1);

ubound1 = tmp1;
objCusResult.setLBound(lbound1);
objCusResult.setUBound(ubound1);
if(lbound1.equals(ubound1))
objCusResult.setRet(1);
else
objCusResult.setRet(2);

return objCusResult;
//objCusResult.setRet(lbound1);
}
}
Jun 21 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: John Hunter | last post by:
I would like to extract the font and family name from a TTF file. I have been looking at fontTools ttLib, which parses the ttf file and provides lots of helpful information, but cannot find the...
15
by: middletree | last post by:
How do I request the actual page name that I'm on? This is going to go into an include file, and depending on which page I'm on, I'd like to do different things. I'm looking for "pagename.asp"
3
by: Baquanb | last post by:
I need to get some text between font tags but I only need the text in the last table. The code i'm using below will get text between all font tags anyone know how I can just get whats in TABLE3...
8
by: Amit | last post by:
I have a master page and a content page but the stylesheet isnt getting applied like how it looks in visual studio design view. The master page is defined like this: <%@ Master Language="VB"...
9
by: Dr. Locke Z2A | last post by:
So I'm writing a bot in python that will be able to do all kinds of weird shit. One of those weird shit is the ability to translate text from one language to another, which I figured I'd use google...
5
by: olaamussah | last post by:
Hi, i just started learning perl which i would use for my uni. project unfortunately. Well, this is a simple user login page i tried to create but i cant get it to work. Can someone please check this...
1
by: neovantage | last post by:
Hey, I have read an email template and sending emails through php mail function. It shows html code when i open that received email in outlook express but it shows normal content in hotmail, yahoo,...
9
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
9
vikas251074
by: vikas251074 | last post by:
I am not getting date value in spite of my good effort. This code was working in my last office where I work. Now I am trying to work at my home pc. but not getting date value. Any can help me why...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.