473,657 Members | 2,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting font from file

5 New Member
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 3018
anubhav vij
27 New Member
get ur file .doc which contains the marathi or any other code and load it in to your swing .
1.
// String documentPath = "C:\\whateverTh ePathIs.doc";
// 2.
// String command = "cmd /c start " + documentPath ;
// 3.
// Runtime.getRunt ime().exec(comm and);
//

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
dineshchothe
5 New Member
get ur file .doc which contains the marathi or any other code and load it in to your swing .
1.
// String documentPath = "C:\\whateverTh ePathIs.doc";
// 2.
// String command = "cmd /c start " + documentPath ;
// 3.
// Runtime.getRunt ime().exec(comm and);
//

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
anubhav vij
27 New Member
import java.io.*;



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

try{
Runtime.getRunt ime().exec("oow riter -o /home/the exact path where your file exists");
}catch(IOExcept ion e){
System.out.prin tln(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
dineshchothe
5 New Member
import java.io.*;



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

try{
Runtime.getRunt ime().exec("oow riter -o /home/the exact path where your file exists");
}catch(IOExcept ion e){
System.out.prin tln(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.d vbttyogesh) 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(Strin g l) {
lbound = l;
}
public void setUBound(Strin g 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.prin tln("Fist give map file then Input file & OutputFile");
/* int i=args.length;
int j=3;
System.out.prin tln(i);*/
try
{
/*if(args.length ==3)
System.out.prin tln(" ok");
else
System.out.prin tln(" 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.hasMor eTokens())
{
String key= st.nextToken();
String val= st.nextToken();
tm.put(key,val) ;//Entered value in Map
}
}
//System.out.prin tln("Asending Map :");
Set set = tm.entrySet();

Iterator tit =set.iterator() ;
while(tit.hasNe xt()){
Map.Entry me =(Map.Entry)tit .next();
//System.out.prin tln(me.getKey() +":"+me.getValu e());

}




fin.close();
}
catch (IOException e)
{
System.err.prin tln ("Unable to read from file1");
System.exit(-1);
}
catch (ArrayIndexOutO fBoundsExceptio n e)
{
System.err.prin tln ("it catch "+e);
System.exit(-1);
}

//mappingFileBegi n();//call to vector map funct1ion
//System.out.prin tln("Vec :"+vec.firstEle ment().toString ());
//opening input file
FileInputStream finIn;
FileOutputStrea m finOut;
String line=null;
String uniLine=null;
try
{
finIn = new FileInputStream (ip);
DataInputStream in = new DataInputStream (finIn);

finOut = new FileOutputStrea m (op);

DataOutputStrea m out = new DataOutputStrea m(finOut);

while (in.available() !=0)
{
line = in.readLine();
uniLine=convert Line(line);
//out.writeChars( uniLine);
out.writeBytes( uniLine);
out.writeByte(' \n');
//out.writeUTF(un iLine);
}
finIn.close();
finOut.close();
if(uniLine.leng th()>0)
{
//System.out.prin tln("o/p File Contents:"+uniL ine);
// outfptr<<uniLin e<<endl;
}}
catch (IOException e)
{
System.err.prin tln ("Unable to read from file 2");
System.exit(-1);
}

catch (ArrayIndexOutO fBoundsExceptio n e)
{
System.err.prin tln ("yogesh"+e) ;
System.exit(-1);
}
}


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

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

uniWord = convertWord(wor d);

if(DEBUG)
System.out.prin tln("\nConverte d Word: "+uniWord); ;
uniLine += uniWord;

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

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

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

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

// lower_bound=tm. firstEntry().to String();
// upper_bound=tm. lastEntry().toS tring();
for(i=0;i<len;i ++){
if(flag==0){ //-->if (flag==0 && word[i]){
akshar += Charword[i];
if(DEBUG) {
System.out.prin tln("\nreading "+Charword[i]);
}
}
if(DEBUG)
System.out.prin tln("\ncalling lower bound with "+akshar);
//bound_result = custom_bounds(a kshar,lower_bou nd,upper_bound) ;
objCus = custom_bounds(a kshar,lower_bou nd,upper_bound) ;
flag=0;
bound_result = objCus.getRet() ;
lower_bound = objCus.getLBoun d();
upper_bound = objCus.getUBoun d();
// Switch Remaining...
switch(bound_re sult){
case 0: //no entry found in mapping
if(DEBUG)
System.out.prin tln("No results found, Cache: "+cached_result );
if(cached_resul t.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.prin tln("Cahe Akasher1 :"+akshar);
int aks=akshar.leng th()-1;
akshar = akshar.substrin g(aks,aks+1);//->akshar = akshar[akshar.size()-1];
// System.out.prin tln("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().t oString();
upper_bound = tm.lastKey().to String();
break;
case 1: //exactly one result, cache it
// cached_result = lower_bound->second;//Remain
// System.out.prin tln("Exact Match :"+lower_bound) ;
//cached_result =mp.get(lbound1 G).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.prin tln("Mul Match Lower :"+lower_bou nd + " Mul Upper :" + upper_bound);
cached_result = lower_bound;
// System.out.prin tln("Lower Bound:"+lbound1 G+" AksharExact:"+a kshar+"cached_r esult:"+cached_ result);
break;
}
}
if(cached_resul t.length()>0)
uniWord += cached_result;
if(DEBUG)
System.out.prin tln("Returning from convertWord: "+uniWord);
return uniWord;
}


public static CusResult custom_bounds(S tring akshar,String lbound1,String ubound1){
CusResult objCusResult = new FileJavaNew5.Cu sResult();
Set set = tm.entrySet();
Iterator tit =set.iterator() ;
int alen=akshar.len gth();
//System.out.prin tln("Cus Akshar :"+akshar);
String tmp="";
String tmp1="";
int count=0;
while(tit.hasNe xt()){
Map.Entry me =(Map.Entry)tit .next();
tmp=me.getKey() .toString();
count++;
//System.out.prin tln("Sub String :" +tmp.substring( 0,alen));
if(tmp.length() >=alen) {
if(tmp.substrin g(0,alen).equal s(akshar)) {
tmp1=me.getValu e().toString();
break;
}
}
}
if(tit.hasNext( ) == false) // if no match found
//return 0;
return objCusResult;
lbound1 = tmp1;

NavigableMap nmp = tm.descendingMa p();
set = nmp.entrySet();
tit = set.iterator();
while(tit.hasNe xt()){
Map.Entry me =(Map.Entry)tit .next();
tmp=me.getKey() .toString();
if(tmp.length() >=alen) {
if(tmp.substrin g(0,alen).equal s(akshar)) {
tmp1=me.getValu e().toString();
break;
}
}
}
//System.out.prin tln("Upper = "+tmp1);

ubound1 = tmp1;
objCusResult.se tLBound(lbound1 );
objCusResult.se tUBound(ubound1 );
if(lbound1.equa ls(ubound1))
objCusResult.se tRet(1);
else
objCusResult.se tRet(2);

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

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

Similar topics

0
2850
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 name. >>> from fontTools import ttLib >>> tt = ttLib.TTFont("cour.ttf") tt seems like a good place to find it, but I can't. The data appear to be in the 'name' field
15
2118
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
3782
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 font tags. $url = "http://www.mysite.com"; $data = implode("", file($url)); preg_match_all ("/<td>(*?)<\/td>/", $data, $matches); foreach ($matches as $match) {
8
13515
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" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
9
3121
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 translate to do. Here is the section for translation that I'm having trouble with: elif(line=="translate"): #if user inputs translate text="" for i in range(abuindex+2, len(line)): #concantenate all
5
5736
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 out. Corrections would be highly appreciated. The code: use strict; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBI; $CGI::POST_MAX = 1024 * 1000; sub print_login_form($);
1
2818
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, gmail account. This is how it view me HTML code in outlook ----Original Message----- From: Sent: None To: <email removed> Subject: File Uploaded by <email removed>
9
2614
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 the main floors of the main house: Part C: Gross Floor Area of the basement or cellar: Part D: Gross Floor Area of the attic:
9
3534
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 this happens. This is my part of code given below. <%@ Language=VBScript%> <%Option Explicit%> <html> <head> <title>SABF</title> <!--#include file="font.css"-->
7
4435
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 surrendered to you. <%@ Language=VBScript%> <%Option Explicit%>
0
8421
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.