0
궁극적으로 휴대 전화에 글꼴 교환기 응용 프로그램을 만들 계획이었습니다. 그러나 일부 글꼴이 제대로 작동하지 않기 때문에 현재 약간의 어려움을 겪고 있습니다. 실제로 제 코드 일 수 있다고 생각합니다. 다른 글꼴 교환기 코드를보고 완벽하게 작동했기 때문에 뭔가 놓칠 수 있습니다. 그래서 제가 알고 싶은 것은 왜 이러한 글꼴들이 작동하지 않는가하는 것입니다. 전화할만한 방법이 있습니까? 이 문제에 대한 조사를 한 결과 import java.awt.Font; 어떤 글꼴이 작동합니다. 내가 나중에 사용자 정의 글꼴을 추가 할 수 있지만이 응용 프로그램에서 작동하도록 내 PC에서 사용할 수있는 모든 글꼴을 갖고 싶습니다.글꼴 changer app. 일부 글꼴이 작동하지 않습니다.
import java.awt.*;
import java.awt.Font.*;
import java.awt.event.*;
import java.applet.Applet;
public class FontChangerForAndroid extends Applet implements ActionListener
{
Button Change;
Button TestOutput;
Choice Fonts;
TextField TestTxt;
Label text;
/***
* Okay, this works so far. Not sure if the comic one isnt working. Or if I just spelled it wrong. I will have to
* look it up in a java Font libaray.
*
* I basically want to make this a function on my entire phone. So i'll have to change it to an android app.
* (I hope it has the Rosemarry font)
* While I'm practicing with this app, I'll add a text box that will let me change the label. Or enter the words
* in the app.
*
*/
public void init(){
setLayout(new FlowLayout());
Fonts = new Choice();
//Some fonts don't work because we I don't know what fonts are in the JGE. Working on how to find them
//Will just add fonts to this system if possible.
Fonts.addItem("Dialog");
Fonts.addItem("Serif");
Fonts.addItem("SansSerif");
Fonts.addItem("Monospaced");
Fonts.addItem("DialogInput");
Fonts.addItem("Calist");
Fonts.addItem("Centbi");
add(Fonts);
TestTxt = new TextField("Enter Text",15);
add(TestTxt);
TestOutput = new Button("Enter");
add(TestOutput);
Change = new Button("Change Font");
add(Change);
text = new Label("Real eye realize real lies");
add(text);
Change.addActionListener(this);
TestOutput.addActionListener(this);
}
public void actionPerformed(ActionEvent evt) {
String item = (String) Fonts.getSelectedItem();
//Gets the selected option from the list and sets the text as the Font.
if (evt.getSource() == Change){
text.setFont(new Font(item, Font.PLAIN, 12));
}
//In this section you can enter something and print it out on the screen.
if (evt.getSource() == TestOutput){
repaint();
}
}
/**
* I'm trying to figure out what code goes here in order for the font to change here also....5/22/13
*
*/
public void paint (Graphics g){
//String item = Fonts.getSelectedItem();
//g.setFont(TestTxt.setFont(new Font(item, Font.PLAIN, 12)));
g.drawString(TestTxt.getText(),20,100);
}
}
registerFont 메서드가 어떻게 작동하는지 예를 들려 줄 수 있습니까? – user2433219
더 큰 그림이 무용하기 때문에이 앱에서 몇 가지 방법을 취하고 있습니다. – user2433219
예제는 [이 대답] (http://stackoverflow.com/a/8365030/418556)을 참조하십시오. –