|
@@ -1,6 +1,9 @@
|
|
|
package com.compdfkit.tools.edit.pdfproperties;
|
|
|
|
|
|
+import android.graphics.Typeface;
|
|
|
import android.os.Bundle;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
@@ -19,11 +22,14 @@ import com.compdfkit.tools.R;
|
|
|
import com.compdfkit.tools.common.views.pdfproperties.basic.CBasicPropertiesFragment;
|
|
|
import com.compdfkit.tools.common.views.pdfproperties.colorlist.CColorListView;
|
|
|
import com.compdfkit.tools.common.utils.view.colorpicker.widget.ColorPickerView;
|
|
|
+import com.compdfkit.tools.common.views.pdfproperties.font.CExternFontSpinnerAdapter;
|
|
|
import com.compdfkit.tools.common.views.pdfproperties.font.CFontSpinnerAdapter;
|
|
|
import com.compdfkit.tools.common.views.pdfproperties.preview.CStylePreviewView;
|
|
|
import com.compdfkit.tools.common.utils.view.sliderbar.CSliderBar;
|
|
|
import com.compdfkit.tools.common.views.pdfstyle.CAnnotStyle;
|
|
|
+import com.compdfkit.ui.utils.CPDFSysFontUtils;
|
|
|
|
|
|
+import java.nio.file.attribute.FileOwnerAttributeView;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -52,7 +58,7 @@ public class CEditTextProperFragment extends CBasicPropertiesFragment implements
|
|
|
private CSliderBar fontSizeSliderBar;
|
|
|
|
|
|
private Spinner fontSpinner;
|
|
|
-
|
|
|
+ CExternFontSpinnerAdapter fontSpinnerAdapter;
|
|
|
private List<View> alignmentViews = new ArrayList<>();
|
|
|
|
|
|
@Override
|
|
@@ -108,12 +114,12 @@ public class CEditTextProperFragment extends CBasicPropertiesFragment implements
|
|
|
previewView.setFontBold(annotStyle.isFontBold());
|
|
|
previewView.setFontItalic(annotStyle.isFontItalic());
|
|
|
previewView.setFontType(annotStyle.getFontType());
|
|
|
-
|
|
|
+ previewView.setFontSize(annotStyle.getFontSize());
|
|
|
List<CPDFTextAttribute.FontNameHelper.FontType> fontTypes = new ArrayList<>();
|
|
|
fontTypes.add(CPDFTextAttribute.FontNameHelper.FontType.Courier);
|
|
|
fontTypes.add(CPDFTextAttribute.FontNameHelper.FontType.Helvetica);
|
|
|
fontTypes.add(CPDFTextAttribute.FontNameHelper.FontType.Times_Roman);
|
|
|
- CFontSpinnerAdapter fontSpinnerAdapter = new CFontSpinnerAdapter(getContext(), fontTypes);
|
|
|
+ fontSpinnerAdapter = new CExternFontSpinnerAdapter(getContext(), fontTypes, CPDFSysFontUtils.GetSysFontName());
|
|
|
fontSpinner.setAdapter(fontSpinnerAdapter);
|
|
|
|
|
|
switch (annotStyle.getFontType()) {
|
|
@@ -179,8 +185,13 @@ public class CEditTextProperFragment extends CBasicPropertiesFragment implements
|
|
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
|
if (viewModel != null) {
|
|
|
setUpdatePropertyType(CAnnotStyle.UpdatePropertyType.FontType);
|
|
|
- CPDFTextAttribute.FontNameHelper.FontType fontType = (CPDFTextAttribute.FontNameHelper.FontType) fontSpinner.getItemAtPosition(position);
|
|
|
- viewModel.getStyle().setFontType(fontType);
|
|
|
+ if (position < fontSpinnerAdapter.getStandardFontCount()) {
|
|
|
+ CPDFTextAttribute.FontNameHelper.FontType fontType = (CPDFTextAttribute.FontNameHelper.FontType) fontSpinner.getItemAtPosition(position);
|
|
|
+ viewModel.getStyle().setFontType(fontType);
|
|
|
+ } else {
|
|
|
+ String fontName = (String) fontSpinner.getItemAtPosition(position);
|
|
|
+ viewModel.getStyle().setExternFontName(fontName);
|
|
|
+ }
|
|
|
setUpdatePropertyType(CAnnotStyle.UpdatePropertyType.All);
|
|
|
}
|
|
|
}
|
|
@@ -194,13 +205,7 @@ public class CEditTextProperFragment extends CBasicPropertiesFragment implements
|
|
|
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- if (v.getId() == R.id.tv_font_type) {
|
|
|
- showFontTypeFragment(null, fontType -> {
|
|
|
- if (viewModel != null) {
|
|
|
- viewModel.getStyle().setFontType(fontType);
|
|
|
- }
|
|
|
- });
|
|
|
- } else if (v.getId() == R.id.iv_font_bold) {
|
|
|
+ if (v.getId() == R.id.iv_font_bold) {
|
|
|
tvFontBold.setSelected(!tvFontBold.isSelected());
|
|
|
if (viewModel != null) {
|
|
|
setUpdatePropertyType(CAnnotStyle.UpdatePropertyType.Bold);
|
|
@@ -288,6 +293,24 @@ public class CEditTextProperFragment extends CBasicPropertiesFragment implements
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onChangeAnnotExternFontType(String fontName) {
|
|
|
+ if (previewView != null) {
|
|
|
+ List<String> fontList = CPDFSysFontUtils.getSysFontPathList();
|
|
|
+ String font = "";
|
|
|
+ for (String item : fontList) {
|
|
|
+ if (TextUtils.isEmpty(item)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (item.contains(fontName + ".")) {
|
|
|
+ font = item;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ previewView.setExternFontType(font);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onChangeAnnotFontBold(boolean bold) {
|
|
|
if (previewView != null) {
|